﻿using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;
using Rabbit.Domain.Entity;

namespace Rabbit.Domain
{
    public partial class RbacContext : DbContext
    {
        public RbacContext()
        {
        }

        public RbacContext(DbContextOptions<RbacContext> options)
            : base(options)
        {
        }

        public virtual DbSet<Animal> Animals { get; set; } = null!;
        public virtual DbSet<Breed> Breeds { get; set; } = null!;
        public virtual DbSet<Butcher> Butchers { get; set; } = null!;
        public virtual DbSet<Gongyingshang> Gongyingshangs { get; set; } = null!;
        public virtual DbSet<Good> Goods { get; set; } = null!;
        public virtual DbSet<Goodinfo> Goodinfos { get; set; } = null!;
        public virtual DbSet<Health> Healths { get; set; } = null!;
        public virtual DbSet<Machining> Machinings { get; set; } = null!;
        public virtual DbSet<Machiningenterprise> Machiningenterprises { get; set; } = null!;
        public virtual DbSet<Simg> Simgs { get; set; } = null!;
        public virtual DbSet<Spimg> Spimgs { get; set; } = null!;
        public virtual DbSet<Tcompany> Tcompanies { get; set; } = null!;
        public virtual DbSet<Timg> Timgs { get; set; } = null!;
        public virtual DbSet<Tuzai> Tuzais { get; set; } = null!;
        public virtual DbSet<Ycompany> Ycompanies { get; set; } = null!;
        public virtual DbSet<Yimg> Yimgs { get; set; } = null!;

        public virtual DbSet<province> provinces { get; set; } = null!;
        public virtual DbSet<city> citys { get; set; } = null!;
        public virtual DbSet<area> areas { get; set; } = null!;
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
////#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
                optionsBuilder.UseMySql("server=localhost;uid=root;pwd=123456;database=Rabbit", Microsoft.EntityFrameworkCore.ServerVersion.Parse("8.0.37-mysql"));
            }
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.UseCollation("utf8mb4_0900_ai_ci")
                .HasCharSet("utf8mb4");

            modelBuilder.Entity<Animal>(entity =>
            {
                entity.ToTable("animal");

                entity.Property(e => e.AnimalId).ValueGeneratedNever();

                entity.Property(e => e.AnimalImages).HasMaxLength(255);
            });

            modelBuilder.Entity<Breed>(entity =>
            {
                entity.ToTable("breed");

                entity.Property(e => e.BreedId).ValueGeneratedNever();

                entity.Property(e => e.BreedBrand).HasMaxLength(255);

                entity.Property(e => e.BreedCome).HasMaxLength(255);

                entity.Property(e => e.BreedName).HasMaxLength(255);

                entity.Property(e => e.BreedPerson).HasMaxLength(255);

                entity.Property(e => e.BreedPut).HasMaxLength(255);
            });

            modelBuilder.Entity<Butcher>(entity =>
            {
                entity.ToTable("butcher");

                entity.Property(e => e.ButcherId).ValueGeneratedNever();

                entity.Property(e => e.ButcherBatch).HasMaxLength(255);

                entity.Property(e => e.ButcherEtime).HasMaxLength(255);

                entity.Property(e => e.ButcherStime).HasMaxLength(255);

                entity.Property(e => e.ButcherWeight).HasMaxLength(255);
            });

            modelBuilder.Entity<Gongyingshang>(entity =>
            {
                entity.HasKey(e => e.Gysid)
                    .HasName("PRIMARY");

                entity.ToTable("gongyingshang");

                entity.Property(e => e.Gysid)
                    .ValueGeneratedNever()
                    .HasColumnName("GYSId");

                entity.Property(e => e.BaoCaiImage).HasMaxLength(255);

                entity.Property(e => e.Baocai).HasMaxLength(255);

                entity.Property(e => e.Flimage)
                    .HasMaxLength(255)
                    .HasColumnName("FLImage");

                entity.Property(e => e.FuLiao).HasMaxLength(255);

                entity.Property(e => e.Tianjiaji).HasMaxLength(255);

                entity.Property(e => e.Tjjimage)
                    .HasMaxLength(255)
                    .HasColumnName("TJJImage");

                entity.Property(e => e.Ylimage)
                    .HasMaxLength(255)
                    .HasColumnName("YLImage");

                entity.Property(e => e.Yuanlian).HasMaxLength(255);
            });

            modelBuilder.Entity<Good>(entity =>
            {
                entity.ToTable("goods");

                entity.Property(e => e.GoodId).ValueGeneratedNever();

                entity.Property(e => e.GoodName).HasMaxLength(255);
            });

            modelBuilder.Entity<Goodinfo>(entity =>
            {
                entity.ToTable("goodinfo");

                entity.Property(e => e.GoodInfoId).ValueGeneratedNever();

                entity.Property(e => e.Batch).HasMaxLength(255);

                entity.Property(e => e.CreateName).HasMaxLength(255);

                entity.Property(e => e.CreateTime).HasColumnType("datetime");

                entity.Property(e => e.GoodCompany).HasMaxLength(255);

                entity.Property(e => e.GoodImages).HasMaxLength(255);

                entity.Property(e => e.Information).HasMaxLength(255);

                entity.Property(e => e.IsDel).HasColumnType("bit(2)");

                entity.Property(e => e.Production)
                    .HasMaxLength(255)
                    .HasColumnName("production");

                entity.Property(e => e.UpdateName).HasMaxLength(255);
            });

            modelBuilder.Entity<Health>(entity =>
            {
                entity.ToTable("health");

                entity.Property(e => e.HealthId).ValueGeneratedNever();

                entity.Property(e => e.HealthIdea).HasMaxLength(255);

                entity.Property(e => e.HealthStyle).HasMaxLength(255);

                entity.Property(e => e.IsDel).HasColumnType("bit(2)");
            });

            modelBuilder.Entity<Machining>(entity =>
            {
                entity.ToTable("machining");

                entity.Property(e => e.MachiningId).ValueGeneratedNever();

                entity.Property(e => e.MachinClass).HasMaxLength(255);

                entity.Property(e => e.MachinFuZe).HasMaxLength(255);
            });

            modelBuilder.Entity<Machiningenterprise>(entity =>
            {
                entity.ToTable("machiningenterprise");

                entity.Property(e => e.MachiningEnterpriseId).ValueGeneratedNever();

                entity.Property(e => e.MachiningEnterpriseName).HasMaxLength(255);

                entity.Property(e => e.MachiningEnterpriseNumber).HasMaxLength(255);
            });

            modelBuilder.Entity<Simg>(entity =>
            {
                entity.HasKey(e => e.ShenId)
                    .HasName("PRIMARY");

                entity.ToTable("simg");

                entity.Property(e => e.ShenId).ValueGeneratedNever();

                entity.Property(e => e.ShenImages).HasMaxLength(255);
            });

            modelBuilder.Entity<Spimg>(entity =>
            {
                entity.HasKey(e => e.Spid)
                    .HasName("PRIMARY");

                entity.ToTable("spimg");

                entity.Property(e => e.Spid)
                    .ValueGeneratedNever()
                    .HasColumnName("SPId");

                entity.Property(e => e.Spimages)
                    .HasMaxLength(255)
                    .HasColumnName("SPImages");
            });

            modelBuilder.Entity<Tcompany>(entity =>
            {
                entity.ToTable("tcompany");

                entity.Property(e => e.TcompanyId)
                    .ValueGeneratedNever()
                    .HasColumnName("TCompanyId");

                entity.Property(e => e.TcompanyArea)
                    .HasMaxLength(255)
                    .HasColumnName("TCompanyArea");

                entity.Property(e => e.TcompanyCity)
                    .HasMaxLength(255)
                    .HasColumnName("TCompanyCity");

                entity.Property(e => e.TcompanyInfo)
                    .HasMaxLength(255)
                    .HasColumnName("TCompanyInfo");

                entity.Property(e => e.TcompanyName)
                    .HasMaxLength(255)
                    .HasColumnName("TCompanyName");

                entity.Property(e => e.TcompanyProvince)
                    .HasMaxLength(255)
                    .HasColumnName("TCompanyProvince");

                entity.Property(e => e.TcompanyTime)
                    .HasMaxLength(255)
                    .HasColumnName("TCompanyTime");
            });

            modelBuilder.Entity<Timg>(entity =>
            {
                entity.HasKey(e => e.TuId)
                    .HasName("PRIMARY");

                entity.ToTable("timg");

                entity.Property(e => e.TuId).ValueGeneratedNever();

                entity.Property(e => e.TuImages).HasMaxLength(255);
            });

            modelBuilder.Entity<Tuzai>(entity =>
            {
                entity.HasKey(e => e.TuId)
                    .HasName("PRIMARY");

                entity.ToTable("tuzai");

                entity.Property(e => e.TuId).ValueGeneratedNever();

                entity.Property(e => e.TuZaiImage).HasMaxLength(255);
            });

            modelBuilder.Entity<Ycompany>(entity =>
            {
                entity.HasKey(e => e.CompanyId)
                    .HasName("PRIMARY");

                entity.ToTable("ycompany");

                entity.Property(e => e.CompanyId).ValueGeneratedNever();

                entity.Property(e => e.CompanyBoss).HasMaxLength(255);

                entity.Property(e => e.CompanyName).HasMaxLength(255);

                entity.Property(e => e.CompanyNumber).HasMaxLength(255);
            });

            modelBuilder.Entity<Yimg>(entity =>
            {
                entity.HasKey(e => e.YimageId)
                    .HasName("PRIMARY");

                entity.ToTable("yimg");

                entity.Property(e => e.YimageId)
                    .ValueGeneratedNever()
                    .HasColumnName("YImageId");

                entity.Property(e => e.YimageName)
                    .HasMaxLength(255)
                    .HasColumnName("YImageName");
            });

            //省
            modelBuilder.Entity<province>(entity =>
            {
                entity.HasKey(e => e.ProvinceId)
                    .HasName("PRIMARY");

                entity.ToTable("province");

                entity.Property(e => e.ProvinceId).ValueGeneratedNever();

                entity.Property(e => e.ProvinceName).HasMaxLength(255);
            });

            //市
            modelBuilder.Entity<city>(entity =>
            {
                entity.HasKey(e => e.ProvinceId)
                    .HasName("PRIMARY");

                entity.ToTable("city");

                entity.Property(e => e.CityId).ValueGeneratedNever();

                entity.Property(e => e.CityName).HasMaxLength(255);
                entity.Property(e => e.ProvinceId).HasColumnType("int");

            });

            //区
            modelBuilder.Entity<area>(entity =>
            {
                entity.HasKey(e => e.AreaId)
                    .HasName("PRIMARY");

                entity.ToTable("area");

                entity.Property(e => e.AreaId).ValueGeneratedNever();

                entity.Property(e => e.AreaName).HasMaxLength(255);
                entity.Property(e => e.CityId).HasColumnType("int");

            });

            OnModelCreatingPartial(modelBuilder);
        }

        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
    }
}
